package cn.cjy.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import cn.cjy.model.Article;
import cn.cjy.service.ArticleService;
import cn.cjy.service.impl.ArticleServiceImpl;


/**
 * Servlet implementation class AdminSelectArticleLikeServlet
 */
@WebServlet("/AdminSelectArticleLikeServlet")
public class AdminSelectArticleLikeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	List<Article> ar=null;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AdminSelectArticleLikeServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		String contrller= request.getParameter("contrller");
		String key=request.getParameter("key");
		if(contrller.equals("标题")) {
			ArticleService articleService=new ArticleServiceImpl();
		    ar=articleService.selectArticleByTitle(key);
		}else {
			ArticleService articleService=new ArticleServiceImpl();
		    ar=articleService.selectArticleByUserinfo(key);
		}
		
	    
	    request.setAttribute("articles", ar);
		RequestDispatcher dispatcher=request.getRequestDispatcher("admin/article.jsp");
		dispatcher.forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
